package top.healthylife.gateway.platformchain.api.black.business.query;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.healthylife.basics.utils.exception.BusinessException;
import top.healthylife.gateway.core.service.ParentFace;
import top.healthylife.gateway.core.util.SystemConfigUtils;
import top.healthylife.gateway.dto.annotation.ApiServiceExplain;
import top.healthylife.gateway.platform.chain.dto.business.query.req.ChainBusinessBlackListQueryReqDto;
import top.healthylife.gateway.platform.chain.dto.business.query.res.ChainBusinessBlackListQueryResDto;
import top.healthylife.gateway.platformchain.api.config.SystemConfig;
import top.healthylife.gateway.platformchain.api.util.OutHttpUtil;



/**
 * @author : GaoZeXi
 * @date 2021/5/7 17:54
 */
@Slf4j
@Service
@ApiServiceExplain(price = 20, apiName = "企业黑名单-查询", info = "查询企业黑名单数据")
public class BusinessBlackListQueryApi implements ParentFace<ChainBusinessBlackListQueryReqDto, ChainBusinessBlackListQueryResDto> {
    private static final String URL = OutHttpUtil.BASE_URL+"/bcapi/api/blacklist/enterprise?enterpriseCode=";
    @Override
    public ChainBusinessBlackListQueryResDto execute(ChainBusinessBlackListQueryReqDto reqDto) {
        String socialCreditCode = reqDto.getSocialCreditCode();
        if(ObjectUtil.isEmpty(socialCreditCode)){
            throw new BusinessException("企业社会信用代码不能为空");
        }
        return OutHttpUtil.get(URL+socialCreditCode, (SystemConfig) SystemConfigUtils.get()
                , ChainBusinessBlackListQueryResDto.class);
    }
}
